package com.ruoyi.ax.service.impl;

import java.util.List;

import com.ruoyi.ax.domain.AxGood;
import com.ruoyi.ax.mapper.AxGoodMapper;
import com.ruoyi.ax.mapper.AxOrderMapper;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ax.mapper.AxAuthorizationSellMapper;
import com.ruoyi.ax.domain.AxAuthorizationSell;
import com.ruoyi.ax.service.IAxAuthorizationSellService;

/**
 * 委拍记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-07
 */
@Service
public class AxAuthorizationSellServiceImpl implements IAxAuthorizationSellService 
{
    @Autowired
    private AxAuthorizationSellMapper axAuthorizationSellMapper;

    @Autowired
    private AxOrderMapper axOrderMapper;

    @Autowired
    private AxGoodMapper axGoodMapper;

    @Autowired
    private ISysUserService userService;

    /**
     * 查询委拍记录
     * 
     * @param id 委拍记录主键
     * @return 委拍记录
     */
    @Override
    public AxAuthorizationSell selectAxAuthorizationSellById(Integer id)
    {
        return axAuthorizationSellMapper.selectAxAuthorizationSellById(id);
    }

    /**
     * 查询委拍记录列表
     * 
     * @param axAuthorizationSell 委拍记录
     * @return 委拍记录
     */
    @Override
    public List<AxAuthorizationSell> selectAxAuthorizationSellList(AxAuthorizationSell axAuthorizationSell)
    {
        return axAuthorizationSellMapper.selectAxAuthorizationSellList(axAuthorizationSell);
    }


    @Override
    public List<AxAuthorizationSell> selectAxAuthorizationSellWithOrderList(AxAuthorizationSell axAuthorizationSell)
    {
        List<AxAuthorizationSell> list = axAuthorizationSellMapper.selectAxAuthorizationSellList(axAuthorizationSell);
        for(AxAuthorizationSell axAuthorizationSell1:list){
            AxGood axGood=axGoodMapper.selectAxGoodById(axAuthorizationSell1.getGoodId());
            axAuthorizationSell1.setAxGood(axGood==null?new AxGood():axGood );
            axAuthorizationSell1.setSysUser(userService.selectUserById(axAuthorizationSell1.getSysUserId()));
        }
        return list;
    }



    /**
     * 新增委拍记录
     * 
     * @param axAuthorizationSell 委拍记录
     * @return 结果
     */
    @Override
    public int insertAxAuthorizationSell(AxAuthorizationSell axAuthorizationSell)
    {
        axAuthorizationSell.setCreateTime(DateUtils.getNowDate());
        return axAuthorizationSellMapper.insertAxAuthorizationSell(axAuthorizationSell);
    }

    /**
     * 修改委拍记录
     * 
     * @param axAuthorizationSell 委拍记录
     * @return 结果
     */
    @Override
    public int updateAxAuthorizationSell(AxAuthorizationSell axAuthorizationSell)
    {
        axAuthorizationSell.setUpdateTime(DateUtils.getNowDate());
        return axAuthorizationSellMapper.updateAxAuthorizationSell(axAuthorizationSell);
    }

    /**
     * 批量删除委拍记录
     * 
     * @param ids 需要删除的委拍记录主键
     * @return 结果
     */
    @Override
    public int deleteAxAuthorizationSellByIds(Integer[] ids)
    {
        return axAuthorizationSellMapper.deleteAxAuthorizationSellByIds(ids);
    }

    /**
     * 删除委拍记录信息
     * 
     * @param id 委拍记录主键
     * @return 结果
     */
    @Override
    public int deleteAxAuthorizationSellById(Integer id)
    {
        return axAuthorizationSellMapper.deleteAxAuthorizationSellById(id);
    }
}
